home *** CD-ROM | disk | FTP | other *** search
-
-
- #include "FRApp.h"
-
- bool FRPowerUp::ms_bHideType = false;
-
- TERTTIImplementation(FRPowerUp, TEEngineObject);
- TERTTIImplementation(FROilPuddle, TEEngineObject);
- TERTTIImplementation(FREMPMine, TEEngineObject);
- TERTTIImplementation(FREMPRocket, TEEngineObject);
-
- FRPowerUp::FRPowerUp(TEVector &rPos)
- {
- TEVector Min, Max, Tmp;
-
- m_Center = rPos;
- m_Center.m_fY = 10.0f;
- Tmp = TEVector(5.0f, 5.0f, 5.0f);
- Min = m_Center - Tmp;
- Max = m_Center + Tmp;
- m_pBoundingVolume = new TEAABoundingBox(Min, Max);
-
- m_ulRespawnTime = 0;
- m_lType = TERandM(4)-1;
- UpdateModel();
-
- m_bShadow = ((FRApp*) FRApp::GetApplication())->GetDetails() <= MEDIUM;
- }
-
- void FRPowerUp::Animate(UInt32 ulDeltaT, TEEngine* pEngine)
- {
- if(m_ulRespawnTime == 0)
- {
- m_Rotation.m_fY += ulDeltaT * 0.18f;
- }
- else
- {
- m_ulRespawnTime += ulDeltaT;
-
- if(m_ulRespawnTime > 25000)
- {
- m_ulRespawnTime = 0;
- m_lType = TERandM(4)-1;
- m_bClip = true;
- UpdateModel();
- }
- }
- }
-
- void FRPowerUp::OnClip(TEEngineObject* pInfluencer)
- {
- if(TEIsDerivedFromClass(FRCar, pInfluencer))
- {
- FRCar* pCar = (FRCar*) pInfluencer;
- m_ulRespawnTime = 1;
- SafeDelete(m_pModelRef);
- m_bClip = false;
- pCar->SetPowerUp(m_lType);
- }
- }
-
- bool FRPowerUp::VolStaticInfluence(UInt32 ulDeltaT, TEEngineObject* pObject)
- {
- return Clips(*pObject->GetBoundingVolume());
- }
-
- void FRPowerUp::UpdateModel(void)
- {
- TEString Name;
-
- if(ms_bHideType)
- {
- Name = "question.tmf";
- m_Rotation.m_fX = 0.0f;
- m_bTransparency = true;
- }
- else
- {
- switch(m_lType){
- default:
- case POWERUP_N2O:
- Name = "gasbottle.tmf";
- m_Rotation.m_fX = 0.0f;
- break;
- case POWERUP_ROCKET:
- Name = "rocket.tmf";
- m_Rotation.m_fX = 90.0f;
- break;
- case POWERUP_MINE:
- Name = "mine.tmf";
- m_Rotation.m_fX = 90.0f;
- break;
- case POWERUP_OIL:
- Name = "oilcan.tmf";
- m_Rotation.m_fX = 0.0f;
- break;
- };
-
- m_bTransparency = false;
- }
-
- m_pModelRef = TEModelManager::GetModelManager()->GetModel(Name);
-
- TEAssert(m_pModelRef);
- }
-
- void FRPowerUp::RenderShadow(TERenderer* pRender, TECamera* pCam,
- TELight* pLights, TEShadowMethod DefaultMethod,
- bool bMoreThanOneShadow)
- {
- TEMatrix3x3 RotY;
- TEVector Forward, Center;
- Float fWidth, fHeight;
-
- if(!m_bShadow || m_ulRespawnTime != 0)
- return;
-
- if(!ms_bHideType)
- {
- switch(m_lType){
- default:
- case POWERUP_N2O:
- fWidth = 5.0f;
- fHeight = 5.0f;
- break;
- case POWERUP_ROCKET:
- fWidth = 3.0f;
- fHeight = 12.0f;
- break;
- case POWERUP_MINE:
- fWidth = 6.0f;
- fHeight = 2.5f;
- break;
- case POWERUP_OIL:
- fWidth = 2.5f;
- fHeight = 5.0f;
- break;
- };
- }
- else
- {
- fWidth = 11.0f;
- fHeight = 11.0f;
- }
-
- Center = m_Center;
- Forward = TEVector(0.0f, 0.0f, 1.0f);
- RotY.YRotationMatrixDeg(m_Rotation.m_fY);
- Forward = Forward * RotY;
-
- pRender->SetAmbient(192, 192, 192);
- TEEngine::GetEngine()->RenderFakeShadow(Forward, Center, fWidth, fHeight);
- }
-
-
-
- FROilPuddle::FROilPuddle(TEVector &rPos)
- {/*
- TEEngine* pEngine = TEEngine::GetEngine();
- TETerrain* pTerrain = pEngine->GetTerrain();
- TEVector Dir = TEVector(0.0f, -100.0f, 0.0f);
- TEClipInfo Info;
-
- m_pDecal = NULL;
-
- if(pEngine->RayClipsInWorld(rPos, Dir, Info))
- {
- TEString Name = "oil";
- TEString Pak = "racing";
- TETextureReference* pRef = TETextureManager::GetTextureManager()->GetTexture(Name, Pak, false);
-
- m_pDecal = new TEParticleMark(Info.Plane.m_Normal, Info.Intersection, 35.0f);
- m_Center = Info.Intersection;
-
- m_pDecal->SetTexture(pRef);
- m_pDecal->SetLifetime(9999999);
- m_pDecal->SetFading(false, 0);
- }
- else m_Center = rPos;
-
- m_pBoundingVolume = new TEBoundingSphere(m_Center, 15.0f);*/
-
- TEVector Normal = TEVector(0.0f, 1.0f, 0.0f);
- TEString Name = "oil";
- TEString Pak = "racing";
- TETextureReference* pRef = TETextureManager::GetTextureManager()->GetTexture(Name, Pak, false);
-
- m_pDecal = NULL;
- m_Center = rPos;
- m_Center.m_fY = 0;
-
- m_pDecal = new TEParticleMark(Normal, m_Center, 35.0f);
-
- m_pDecal->SetTexture(pRef);
- m_pDecal->SetLifetime(9999999);
- m_pDecal->SetFading(false, 0);
-
-
- m_pBoundingVolume = new TEBoundingSphere(m_Center, 15.0f);
- }
-
- FROilPuddle::~FROilPuddle()
- {
- SafeDelete(m_pDecal);
- };
-
- void FROilPuddle::Render(TERenderer* pRender, TECamera* pCam)
- {
- if(m_pDecal == NULL)
- return;
-
- pRender->EnableDecaling();
-
- m_pDecal->Render(pRender, pCam);
-
- pRender->DisableDecaling();
- }
-
- void FROilPuddle::OnClip(TEEngineObject* pInfluencer)
- {
- if(TEIsDerivedFromClass(FRCar, pInfluencer))
- {
- FRCar *pCar = (FRCar*) pInfluencer;
- pCar->OilHit();
- }
- }
-
- bool FROilPuddle::VolStaticInfluence(UInt32 ulDeltaT, TEEngineObject* pObject)
- {
- if(TEIsDerivedFromClass(FRCar, pObject))
- return m_pBoundingVolume->IntersectsVolume(*pObject->GetBoundingVolume());
- else return false;
- }
-
-
-
- FREMPMine::FREMPMine(TEVector &rPos)
- {
- TEOBoundingBox *pOBox = new TEOBoundingBox;
- TEAABoundingBox BBox;
- TEVector Min, Max;
- TEString Name = "mine.tmf";
-
- m_Center = rPos;
- m_bStatic = false;
- m_bApplyGravity = m_bAlignToTerrain = true;
- m_fElasticity = m_fFrictionFactor = 0.0f;
-
- m_ulClipState = 0;
-
- m_pModelRef = TEModelManager::GetModelManager()->GetModel(Name);
-
- TEAssert(m_pModelRef);
-
- BBox = m_pModelRef->GetModelBBox();
- BBox.GetData(Min, Max);
-
- pOBox->SetData(m_Center, Min, Max, m_Rotation);
-
- m_pBoundingVolume = pOBox;
-
- m_pSound = NULL;
- }
-
- FREMPMine::~FREMPMine()
- {
- SafeDelete(m_pSound);
- }
-
- void FREMPMine::Animate(UInt32 ulDeltaT, TEEngine* pEngine)
- {
-
- if(m_ulClipState > 0 && m_ulClipState <= 500)
- {
- m_ulClipState += ulDeltaT;
-
- if(m_ulClipState > 500)
- {
- TEEngine::GetEngine()->RemoveParticleSystem(m_pPart);
- m_pPart = NULL;
- }
- }
- }
-
- void FREMPMine::OnClip(TEEngineObject* pInfluencer)
- {
- if(TEIsDerivedFromClass(FRCar, pInfluencer))
- {
- TEString Name;
- TEEngine* pEngine = TEEngine::GetEngine();
- TEVector Up = TEVector(0.0f, 1.0f, 0.0f);
- FRCar *pCar = (FRCar*) pInfluencer;
- pCar->EMPHit();
-
- SafeDelete(m_pModelRef);
- SafeDelete(m_pBoundingVolume);
-
- m_Velocity = TEVector(0,0,0);
- m_bClip = false;
- m_bStatic = true;
- m_bApplyGravity = m_bAlignToTerrain = false;
-
- m_ulClipState = 1;
-
- Name = "emp.ogg";
-
- m_pSound = TESoundManager::GetSoundManager()->GetSound(Name);
- TEAssert(m_pSound);
- m_pSound->Play3D(m_Center, m_Velocity, 0, 1.0f);
-
- m_pPart = new TEParticleFX(m_Center, 1, 15.0f, 1.0f, 180, 0, 0, Up, 20, 1500,
- 255, 15.0f, false, false);
- m_pPart->SetColor(0, 0, 128);
- pEngine->AddParticleSystem(m_pPart);
- }
- else
- {
- m_bStatic = true;
- m_bApplyGravity = m_bAlignToTerrain = false;
- }
- }
-
-
-
- FREMPRocket::FREMPRocket(TEVector &rPos, TEVector &rForward, TEVector &rRot)
- {
- TEOBoundingBox *pOBox = new TEOBoundingBox;
- TEAABoundingBox BBox;
- TEVector Min, Max;
- TEString Name = "rocket.tmf";
-
- m_Center = rPos;
- m_ParticleDelta = rForward * -7.0f;;
- m_Velocity = rForward * 1000.0f;
- m_Rotation = rRot;
- m_Rotation.m_fX = 90.0f;
- m_bStatic = false;
- m_fElasticity = m_fFrictionFactor = 0.0f;
-
- m_ulClipState = 0;
-
- m_pModelRef = TEModelManager::GetModelManager()->GetModel(Name);
-
- TEAssert(m_pModelRef);
-
- BBox = m_pModelRef->GetModelBBox();
- BBox.GetData(Min, Max);
-
- pOBox->SetData(m_Center, Min, Max, m_Rotation);
-
- m_pBoundingVolume = pOBox;
-
- Max = m_Center + m_ParticleDelta;
- Min = -rForward;
- m_pPart = new TEParticleFX(Max, 2, 4, 1.3f, 0, 0, 0, Min, 250, 1000,
- 255, 1.0f, true, false);
- m_pPart->SetColor(255, 255, 255);
- TEEngine::GetEngine()->AddParticleSystem(m_pPart);
-
- Name = "rocketflight.ogg";
-
- m_pSound = TESoundManager::GetSoundManager()->GetSound(Name);
- TEAssert(m_pSound);
- m_pSound->Play3D(m_Center, m_Velocity, TESOUND_LOOP, 1.0f);
- }
-
- FREMPRocket::~FREMPRocket()
- {
- SafeDelete(m_pSound);
- }
-
- void FREMPRocket::Animate(UInt32 ulDeltaT, TEEngine* pEngine)
- {
- if(m_ulClipState == 0)
- {
- TEVector Tmp = m_Center + m_ParticleDelta;
- m_pPart->MoveToPosition(Tmp);
-
- m_pSound->UpdateProperties(m_Center, m_Velocity);
- }
- else if(m_ulClipState <= 500)
- {
- m_ulClipState += ulDeltaT;
-
- if(m_ulClipState > 500)
- {
- TEEngine::GetEngine()->RemoveParticleSystem(m_pPart);
- m_pPart = NULL;
- }
- }
- }
-
- void FREMPRocket::OnClip(TEEngineObject* pInfluencer)
- {
- TEEngine* pEngine = TEEngine::GetEngine();
- TEString Name;
-
- SafeDelete(m_pSound);
- SafeDelete(m_pModelRef);
- SafeDelete(m_pBoundingVolume);
-
- m_Velocity = TEVector(0,0,0);
- m_bClip = false;
- m_bStatic = true;
-
- Name = "emp.ogg";
-
- m_pSound = TESoundManager::GetSoundManager()->GetSound(Name);
- TEAssert(m_pSound);
- m_pSound->Play3D(m_Center, m_Velocity, 0, 1.0f);
-
- m_ulClipState = 1;
-
- pEngine->RemoveParticleSystem(m_pPart);
- m_pPart = new TEParticleFX(m_Center, 1, 15.0f, 1.0f, 360, 0, 0, m_ParticleDelta, 20, 1500,
- 255, 15.0f, false, false);
- m_pPart->SetColor(0, 0, 128);
- pEngine->AddParticleSystem(m_pPart);
-
- if(TEIsDerivedFromClass(FRCar, pInfluencer))
- {
- FRCar *pCar = (FRCar*) pInfluencer;
- pCar->EMPHit();
- }
- }
-